package config

import "time"

// Config represents the complete system configuration
type Config struct {
	AI         *AIConfig         `mapstructure:"ai" yaml:"ai"`
	System     *SystemConfig     `mapstructure:"system" yaml:"system"`
	Team       *TeamConfig       `mapstructure:"team" yaml:"team"`
	Server     *ServerConfig     `mapstructure:"server" yaml:"server"`
	Actor      *ActorConfig      `mapstructure:"actor" yaml:"actor"`
	Resource   *ResourceConfig   `mapstructure:"resource" yaml:"resource"`
	Monitoring *MonitoringConfig `mapstructure:"monitoring" yaml:"monitoring"`
	Security   *SecurityConfig   `mapstructure:"security" yaml:"security"`
}

// AIConfig holds AI-related configuration
type AIConfig struct {
	Provider    string            `mapstructure:"provider" yaml:"provider"`
	APIKey      string            `mapstructure:"api_key" yaml:"api_key"`
	Model       string            `mapstructure:"model" yaml:"model"`
	MaxTokens   int               `mapstructure:"max_tokens" yaml:"max_tokens"`
	Temperature float64           `mapstructure:"temperature" yaml:"temperature"`
	Timeout     int               `mapstructure:"timeout" yaml:"timeout"`
	Options     map[string]string `mapstructure:"options" yaml:"options"`
}

// SystemConfig holds system-wide configuration
type SystemConfig struct {
	MaxConcurrentTasks int     `mapstructure:"max_concurrent_tasks" yaml:"max_concurrent_tasks"`
	MaxMemoryUsage     string  `mapstructure:"max_memory_usage" yaml:"max_memory_usage"`
	MaxCPUUsage        float64 `mapstructure:"max_cpu_usage" yaml:"max_cpu_usage"`
	LogLevel           string  `mapstructure:"log_level" yaml:"log_level"`
	LogFile            string  `mapstructure:"log_file" yaml:"log_file"`
	WorkspaceDir       string  `mapstructure:"workspace_dir" yaml:"workspace_dir"`
	NumEngineers       int     `mapstructure:"num_engineers" yaml:"num_engineers"`
}

// TeamConfig holds team-related configuration
type TeamConfig struct {
	MaxAgents    int                   `mapstructure:"max_agents" yaml:"max_agents"`
	MaxTeams     int                   `mapstructure:"max_teams" yaml:"max_teams"`
	DefaultRoles []string              `mapstructure:"default_roles" yaml:"default_roles"`
	Roles        map[string]RoleConfig `mapstructure:"roles" yaml:"roles"`
}

// RoleConfig holds role-specific configuration
type RoleConfig struct {
	Name        string            `mapstructure:"name" yaml:"name"`
	Description string            `mapstructure:"description" yaml:"description"`
	Actions     []string          `mapstructure:"actions" yaml:"actions"`
	Priority    int               `mapstructure:"priority" yaml:"priority"`
	Prompts     map[string]string `mapstructure:"prompts" yaml:"prompts"`
}

// ServerConfig represents server-related configuration
type ServerConfig struct {
	Host string `mapstructure:"host" yaml:"host"`
	Port int    `mapstructure:"port" yaml:"port"`
}

// ActorConfig represents actor-related configuration
type ActorConfig struct {
	MaxConcurrent int `mapstructure:"maxConcurrent" yaml:"maxConcurrent"`
	BatchSize     int `mapstructure:"batchSize" yaml:"batchSize"`
	QueueSize     int `mapstructure:"queueSize" yaml:"queueSize"`
}

// ResourceConfig represents resource-related configuration
type ResourceConfig struct {
	MaxCPU    float64 `mapstructure:"maxCPU" yaml:"maxCPU"`
	MaxMemory float64 `mapstructure:"maxMemory" yaml:"maxMemory"`
	MaxTasks  int     `mapstructure:"maxTasks" yaml:"maxTasks"`
}

// MonitoringConfig holds monitoring-related configuration
type MonitoringConfig struct {
	Enabled bool           `mapstructure:"enabled" yaml:"enabled"`
	Metrics []MetricConfig `mapstructure:"metrics" yaml:"metrics"`
}

// MetricConfig holds metric-specific configuration
type MetricConfig struct {
	Type     string        `mapstructure:"type" yaml:"type"`
	Interval time.Duration `mapstructure:"interval" yaml:"interval"`
}

// SecurityConfig holds security-related configuration
type SecurityConfig struct {
	EncryptionEnabled bool          `mapstructure:"encryption_enabled" yaml:"encryption_enabled"`
	AuthRequired      bool          `mapstructure:"auth_required" yaml:"auth_required"`
	TokenExpiry       time.Duration `mapstructure:"token_expiry" yaml:"token_expiry"`
}
